﻿using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace Demo_ImgData
{
    public partial class Frm_ImgData : Form
    {
        public Frm_ImgData()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Bitmap bitmap = (Bitmap)Image.FromFile(@"nature.jpg");
            BitmapData mapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat);
            bitmap.UnlockBits(mapData);
            byte[] imgData = new byte[mapData.Stride * mapData.Height];
            Marshal.Copy(mapData.Scan0, imgData, 0, imgData.Length);
            snsPictureBox1.ShowImage(imgData, bitmap.Width, bitmap.Height, bitmap.PixelFormat);

        }

        private void snsPictureBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            snsPictureBox1.Init();
        }
    }
}
